package com.itheima.service.impl;

import com.itheima.mapper.UserMapper;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.itheima.User;
import com.itheima.result.PageResult;
import com.itheima.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.itheima.User;
@Service
public class UserServiceImpl implements UserService {
     @Autowired
     UserMapper userMapper;

    @Override
    public void delById(Integer id) {
        userMapper.delById(id);
    }
    @Override
    public User update(User user) {
        User user1 = userMapper.update(user);
        return user1;
    }

    /**
     * 分页查询
     * @param currentPage
     * @param pageSize
     * @return
     */
    @Override
    public PageResult pageQuery(Integer currentPage, Integer pageSize) {
        PageHelper.startPage(currentPage,pageSize);
        Page<User> page = userMapper.pageQuery();
        return new PageResult(page.getResult(),page.getTotal());
    }
    @Override
    public User findById(Integer id) {
        return userMapper.findById(id);
    }
}
